using System;
using FluentNHibernate.Mapping;
using FluentNHibernate.Conventions;

namespace Caramel.NHibernate.Entities.Conventions
{
	public class HasManyForeignKeyNamingConvention : IHasManyConvention
	{
		#region IConvention<IManyToOnePart> Members

		public bool Accept(IOneToManyPart target)
		{
			return true;
		}

		public void Apply(IOneToManyPart target)
		{
			target.KeyColumnNames.Clear();
			target.KeyColumnNames.Add(target.EntityType.Name + "ID");
		}

		#endregion
	}
}
